@extends('admin.layout')
@section('content')
   <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                商品管理
                <small>编辑</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 后台主页</a></li>
                <li><a href="#">商品管理</a></li>
                <li class="active">商品编辑</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">快速修改商品</h3>
                        </div><!-- /.box-header -->
                 
                        <!-- form start -->
                        <form role="form" action="{{ url('/admin/goods/update')}}" method='post' enctype='multipart/form-data'>
                                  {{csrf_field()}}
                            <div class="box-body">
                        @if (count($errors) > 0)
                             <div class="alert alert-danger" id='error'>
                               <ul>
                                 @foreach ($errors->all() as $error)
                                   <li>{{ $error }}</li>
                                 @endforeach
                               </ul>
                             </div>
                         @endif

                            <script type="text/javascript">
                                window.onload = function()
                                {
                                    $("#error").hide(3000);
                                }


                            </script>
                      

                                       
                                 
                                  <!-- select -->
                              
                                <div class="form-group">
                                    <label>父类</label>
                                    <select class="form-control" name='sid'>

                               
                                       @foreach($allData as $res)
                                        <option 
                                            @if($data -> sid == $res -> id) 
                                              selected='selected'  
                                            @endif 

                                           {{$res -> id}} 
                                           value="{{$res -> id}}"
                                        >
                                           {{$res -> name}}
                                        </option>
                                       @endforeach
                                    </select>
                                </div>
                                <input type='hidden' name ='id' value="{{$data -> id}}">
                                <div class="form-group">
                                    <label for="exampleInputEmail1">商品名</label>
                                    <input type="text" class="form-control" id="username" name="name"
                                           rplaceholder="请输入商品名称" value="{{$data -> name}}">
                                </div>
                              
                            <div class="form-group">
                                <label for="exampleInputEmail1">价格</label>
                                <input type="text" value="{{ $data -> price }}" name="price" class="form-control" id="exampleInputUsername"
                                       placeholder="请输入价格">
                            </div>
                              <div class="form-group">
                                <label for="exampleInputEmail1">原图片</label> 
                                <img src ="{{$data -> img}}" style="width:100px;eight:100px">
                            </div>
                            
                            <div class="form-group">
                                <label for="exampleInputFile">上传图片</label>
                                <input id="exampleInputFile" type="file" name="img" value=''>
                                <p class="help-block">请选择一张图片，作为新的商品图片。</p>
                            </div>
                            <div class="form-group">
                                <label for="exampleInputFile">商品详情</label>
                                <!-- 加载编辑器的容器 -->
                                <script style="width:100%;height:200px;" id="container" name="content" type="text/plain" >{!! $data -> content !!}
                                </script>
                                <!-- 配置文件 -->
                                <script type="text/javascript" src="{{ url('/ue/ueditor.config.js')}}"></script>
                                <!-- 编辑器源码文件 -->
                                <script type="text/javascript" src="{{ url('/ue/ueditor.all.js')}}"></script>
                                <!-- 实例化编辑器 -->
                                <script type="text/javascript">
                                    var ue = UE.getEditor('container');
                                </script>
                            </div>

                        </div><!-- /.box-body -->

                                    
                                      
                                   
                               
                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">修改信息</button>
                            </div>
                        </form>
                    

                   
                   
                    <!-- Input addon -->
              
            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->


@endsection